package org.jiuling.network.tools.response.verify;

import org.jiuling.network.tools.exception.NetworkToolsRuntimeException;
import org.jiuling.network.tools.response.ResponseData;

/**
 * 响应数据校验
 * @author 紫灵
 * @date 2022年10月19日 10时27分54秒
 */
@Deprecated
public class ResponseDataVerify {
    /**
     * 校验并返回数据
     * @param responseData 响应数据
     * @return 数据
     */
    public static <T> T verifyAndrReturnData(ResponseData<T> responseData){
        return verifyAndrReturnData(responseData,0);
    }

    public static <T> T verifyAndrReturnData(ResponseData<T> responseData,int successCode){
        if(responseData.getCode() != successCode){
            throw new NetworkToolsRuntimeException(responseData.getMsg());
        }
        return responseData.getData();
    }
}
